import React from 'react'
import { Card, Button, Table, Divider, Row, Col, Modal, Form, Input } from 'antd'
import DescriptionList from 'components/DescriptionList'
import styles from './index.less'
import {
  contractOrderType,
  productType,
  contractOrderStatus,
  contractActionType,
  contractChangeType,
  contractChangeBusinessType,
  contractChangeReason
} from 'utils/enumConfig'
import moment from 'moment'
import { LwjDownload } from 'components';

const FormItem = Form.Item

const ViewModal = ({
  subDraft, isSub, currentItem, dispatch, ...auditModalProps
}) => {
  const { Description } = DescriptionList

  const formItemLayout = {
    labelCol: {
      xs: { span: 8, offset: 0 },
      sm: { span: 8, offset: 0 },
    },
    wrapperCol: {
      xs: { span: 8, offset: 0 },
      sm: { span: 8, offset: 0 },
    },
  }
  const currentItemBackup = currentItem.backupSummary;
  /** @namespace currentItem.des */
  /** @namespace currentItem.contractChangeReason */
  /** @namespace currentItem.provinceName */
  /** @namespace currentItem.cityName */
  /** @namespace currentItem.districtName */
  /** @namespace currentItem.checkDes */
  /** @namespace currentItem.changeAmount */
  /** @namespace currentItem.changedAmount */
  /** @namespace currentItem.salesDistributorName */
  return (
    <div>
      <Modal {...auditModalProps}>
        <Card className={styles.card} bordered={false}>
          <DescriptionList size="large"
            title={isSub ? "草稿提交" : "合同变更信息"}
            style={{ marginBottom: 32 }}>
            <Description term="合同编号">{currentItem.contractNum}</Description>
            <Description term="变更类型">{contractChangeType[(currentItem.contractChangeType)]}</Description>
            {currentItem.contractChangeType === 'AMOUNT' && <Description
              term="变更业务类型">{contractChangeBusinessType[(currentItem.contractChangeBusinessType)]}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' && <Description
              term="合同金额">{currentItem.orderAmount}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' && <Description
              term="变更金额">{currentItem.changeAmount}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' && <Description
              term="变更后金额">{currentItem.changedAmount}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' &&
              <Description term="变更原因">{contractChangeReason[(currentItem.contractChangeReason)]}</Description>}

            {currentItem.contractChangeType === 'INFORMATION' &&
              <Description term="收货人">{currentItem.consigneeName}</Description>}
            {currentItem.contractChangeType === 'INFORMATION' &&
              <Description term="收货人手机号">{currentItem.consigneePhoneNum}</Description>}
            {currentItem.contractChangeType === 'INFORMATION' && <Description
              term="收货人地址">{currentItem.provinceName} {currentItem.cityName} {currentItem.districtName} {currentItem.address}</Description>}

            <Description term="门店">{currentItem.salesDistributorName}</Description>
            <Description term="备注">{currentItem.des}</Description>
            {currentItem.contractChangeType === 'INFORMATION' && !_.isEmpty(currentItem.designAttachment) &&
              <Description term="设计方案">{<LwjDownload title={'点击下载'}
                targetUrl={currentItem.designAttachment || ''} />}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' &&
              <Description term="报价方案">{<LwjDownload title={'点击下载'}
                targetUrl={currentItem.quoteAttachment || ''} />}</Description>}
            {!isSub && <Description term="审核备注">{currentItem.checkDes}</Description>}
          </DescriptionList>
          {isSub && <div style={{ float: 'right' }}>
            <Button type="primary" onClick={() => subDraft(true)}>提交草稿</Button>
            <Button type="cancel" onClick={() => subDraft(false)}>取消</Button>
          </div>
          }
        </Card>
       {!isSub && currentItemBackup && <Card className={styles.card} bordered={false}>
          <DescriptionList size="large"
            title={isSub ? "草稿提交" : "原合同信息"}
            style={{ marginBottom: 32 }}>
            <Description term="合同编号">{currentItemBackup.contractNum}</Description>
            {currentItem.contractChangeType === 'AMOUNT' && <Description
              term="合同金额">{currentItemBackup.orderAmount}</Description>}
            {currentItem.contractChangeType === 'INFORMATION' &&
              <Description term="收货人">{currentItemBackup.consigneeName}</Description>}
            {currentItem.contractChangeType === 'INFORMATION' &&
              <Description term="收货人手机号">{currentItemBackup.consigneePhoneNum}</Description>}
            {currentItem.contractChangeType === 'INFORMATION' && <Description
              term="收货人地址">{currentItemBackup.provinceName} {currentItemBackup.cityName} {currentItemBackup.districtName} {currentItemBackup.address}</Description>}

            {currentItem.contractChangeType === 'INFORMATION' && !_.isEmpty(currentItemBackup.designAttachment) &&
              <Description term="设计方案">{<LwjDownload title={'点击下载'}
                targetUrl={currentItemBackup.designAttachment || ''} />}</Description>}
            {currentItem.contractChangeType === 'AMOUNT' &&
              <Description term="报价方案">{<LwjDownload title={'点击下载'}
                targetUrl={currentItemBackup.quoteAttachment || ''} />}</Description>}
          </DescriptionList>
        </Card>}
      </Modal>
    </div>
  )
}

export default ViewModal
